package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProductGasCylinder;
import com.ruoyi.system.service.IProductGasCylinderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 气瓶Controller
 * 
 * @author malang
 * @date 2022-02-02
 */
@RestController
@RequestMapping("/labbase/cylinder")
public class ProductGasCylinderController extends BaseController {
	@Autowired
	private IProductGasCylinderService productGasCylinderService;

	/**
	 * 查询气瓶列表
	 */
	@PreAuthorize("@ss.hasPermi('labdanger:cylinder:query')")
	@GetMapping("/list")
	public TableDataInfo list(ProductGasCylinder productGasCylinder) {
		startPage();
		List<ProductGasCylinder> list = productGasCylinderService.selectProductGasCylinderList(productGasCylinder);
		return getDataTable(list);
	}

	/**
	 * 导出气瓶列表
	 */
	//@PreAuthorize("@ss.hasPermi('labbase:cylinder:export')")
	/*@Log(title = "气瓶", businessType = BusinessType.EXPORT)
	@GetMapping("/export")
	public AjaxResult export(ProductGasCylinder productGasCylinder) {
		List<ProductGasCylinder> list = productGasCylinderService.selectProductGasCylinderList(productGasCylinder);
		ExcelUtil<ProductGasCylinder> util = new ExcelUtil<ProductGasCylinder>(ProductGasCylinder.class);
		return util.exportExcel(list, "cylinder");
	}*/

	/**
	 * 获取气瓶详细信息
	 */
	@PreAuthorize("@ss.hasPermi('labdanger:cylinder:query')")
	@GetMapping(value = "/{id}")
	public AjaxResult getInfo(@PathVariable("id") Long id) {
		return AjaxResult.success(productGasCylinderService.selectProductGasCylinderById(id));
	}

	/**
	 * 新增气瓶
	 */
	@PreAuthorize("@ss.hasPermi('labdanger:cylinder:edit')")
	@Log(title = "气瓶", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody ProductGasCylinder productGasCylinder) {
		return toAjax(productGasCylinderService.insertProductGasCylinder(productGasCylinder));
	}

	/**
	 * 修改气瓶
	 */
	@PreAuthorize("@ss.hasPermi('labdanger:cylinder:edit')")
	@Log(title = "气瓶", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody ProductGasCylinder productGasCylinder) {
		return toAjax(productGasCylinderService.updateProductGasCylinder(productGasCylinder));
	}

	/**
	 * 删除气瓶
	 */
	@PreAuthorize("@ss.hasPermi('labdanger:cylinder:edit')")
	@Log(title = "气瓶", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
	public AjaxResult remove(@PathVariable Long ids) {
		return toAjax(productGasCylinderService.deleteProductGasCylinderById(ids));
	}
}
